//
//  HomeViewCell.swift
//  Beadhouse
//
//  Created by Apple on 2018/10/25.
//  Copyright © 2018年 wangdong. All rights reserved.
//

import UIKit
import SnapKit
class HomeViewCell: UITableViewCell {
  
    var imgView: UIImageView?
    var titleLab: UILabel?
    var despLab :UILabel?
    

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setupUI()
        
    }
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        setupUI()
    }
    func  setupUI(){
        imgView = UIImageView()
        self.addSubview(imgView!)
        
        
        titleLab = UILabel()
        titleLab?.textColor = UIColor.red
        titleLab?.font = UIFont.systemFont(ofSize: 15)
        self.addSubview(titleLab!)
        
        despLab = UILabel()
        despLab?.font = UIFont.systemFont(ofSize: 20)
        despLab?.numberOfLines = 0
        self.addSubview(despLab!)
        
        
        // SnapKit 布局
   
//        imgView?.snp.makeConstraints({ (make) in
//            make.top.left.equalTo(10)
//            make.width.height.equalTo(40)
//        })
//
//        titleLab?.snp.makeConstraints({ (make) in
//            make.top.equalTo(10)
//            make.left.equalTo(((imgView?.snp.right)!)).offset(10)
//            make.right.equalTo(-10)
//            make.height.equalTo(21)
//        })
//        despLab?.snp.makeConstraints({ (make) in
//
//            make.top.equalTo(((titleLab?.snp.bottom)!)).offset(10)
//            make.left.equalTo(((imgView?.snp.right)!)).offset(10)
//            make.right.equalTo(-10)
//            make.bottom.equalTo(-10)
//        })
        
        
        //设置布局 SnapKit  --- >相当去Objective-C中的Masonry
        imgView?.snp.makeConstraints({ (make) in
            make.top.left.equalTo(10)
            make.width.height.equalTo(40)
        })
        
        titleLab?.snp.makeConstraints { (make) in
            make.top.equalTo(10)
            make.left.equalTo((imgView?.snp.right)!).offset(10)
            make.right.equalTo(-10)
            make.height.equalTo(21)
        }
        
        despLab?.snp.makeConstraints { (make) in
            make.top.equalTo((titleLab?.snp.bottom)!).offset(10)
            make.left.equalTo((imgView?.snp.right)!).offset(10)
            make.right.equalTo(-10)
            make.bottom.equalTo(-10)
        }
        
        
    }


}
